package logic;

/**
 * class representing a card for poker game
 * @author Rekin
 *
 */
public class Card{

	private int figure;
	private int color;
	private boolean selected;
	
	/**
	 * card constructor
	 * @param figure card figure
	 * @param color card color
	 */
	public Card(int figure, int color){
		selected=false;
		this.figure=figure;
		this.color=color;
	}	

	/**
	 * @return figure
	 */
	public int getFigure() {
		return figure;
	}

	/**
	 * @param figure
	 */
	public void setFigure(int figure) {
		this.figure = figure;
	}

	/**
	 * @return isSelected
	 */
	public boolean isSelected() {
		return selected;
	}

	/**
	 * @param selected
	 */
	public void setSelected(boolean selected) {
		this.selected = selected;
	}
	
	/**
	 * @return color
	 */
	public int getColor() {
		return color;
	}
	
	/**
	 * @param color
	 */
	public void setColor(int color) {
		this.color = color;
	}

	/**
	 * method for comparing two cards
	 * @param secondCard card to compare
	 * @return -1 when card figure is lower than the given one or 0 when they are equals otherwise 1
	 */
	public int compareToAnotherCard(Card secondCard) {
		if(figure<secondCard.figure)
			return -1;
		else if(figure>secondCard.figure)
			return 1;
		return 0;
	}
	
	/**
	 * @return string representation of card
	 */
	public String toString(){
		StringBuffer b = new StringBuffer();
		if(figure<=10) b.append(""+figure);
		else if(figure==11) b.append("J");
		else if(figure==12) b.append("Q");
		else if(figure==13) b.append("K");
		else if(figure==14) b.append("A");
		if(color==0) b.append("-KI");
		else if(color==1) b.append("-KA");
		else if(color==2) b.append("-PI");
		else if(color==3) b.append("-TR");
		return b.toString();
	}
}
